package com.example.springbootdemo.impot;

import org.springframework.core.io.Resource;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;

public class MyScanFilter implements TypeFilter {
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory)
            throws IOException {
        final ClassMetadata classMetadata = metadataReader.getClassMetadata();
        final ClassMetadata annotationMetadata = metadataReader.getAnnotationMetadata();

        final Resource resource = metadataReader.getResource();

        final String className = classMetadata.getClassName();
        System.out.println("filter is class name:"+className);
        if (className.contains("MyServes")){
            return true;
        }
        return false;
    }
}
